﻿using BookTheBook.Data.Model;
using BookTheBook.Data.NameDefinitions;
using FluentNHibernate.Mapping;

namespace BookTheBook.Data.Mappings
{
    public class RoleMap : ClassMap<Role>
    {
        public RoleMap()
        {
            Table(TableNames.Role);
            Id(x => x.Id).Column(ColumnNames.RoleId);
            Map(x => x.Name).Column(ColumnNames.RoleName);
            HasManyToMany(x => x.Users).Cascade.All().Table(TableNames.RoleToUser).
                                        ParentKeyColumn(ColumnNames.RoleId).
                                        ChildKeyColumn(ColumnNames.UserId);
        }
    }
}
